var mapIds = [350022100, 350022200, 350022300, 350022600, 350022700];
var 准备地图 = 350022010;

function init() {
    em.setProperty("state", 0);
    em.setProperty("leader", "true")
}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance("黑色天堂_Act2_走廊");
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully();
        d.killAllMonsters(false)
    }
    return c
}

function onPlayerRegistered(b, a) {
    a.setReviveCount(-100);
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(15 * 60 * 1000)
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    if (em.getNumberProperty("clear" + mapIds[0]) == 1) {
        b.getAPI().updateMirrorDungeonMap(0, 1, [0])
    }
    em.setProperty("kill", "0");
    em.setProperty("clear", "0");
    em.setProperty("curMap", a)
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function playerExit(b, a) {
    on玩家退场(b, a, false)
}

function onMonsterKilled(b, c) {
    var a = em.getNumberProperty("kill") + 1;
    em.setProperty("kill", a);
    var d = player.getMapId();
    if (player.getMap().getNumMonsters() == 0) {
        if (d == 350022100) {
            player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
            player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100)
        } else {
            if (d == 350022300) {
                player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                player.getAPI().addPopupSay(1540453, 1500, "我感觉前方有邪恶的气息. ", "", 0)
            } else {
                if (d == 350022600) {
                    player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                    player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                    player.getAPI().addPopupSay(1540451, 1500, "已经快到中央走廊了. ", "", 0)
                } else {
                    if (d == 350022700) {
                        player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                        player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                        player.getAPI().addPopupSay(1540453, 1500, "没时间拖延了. \r\n快到甲板上方!", "", 0)
                    }
                }
            }
        }
        em.setProperty("clear" + mapId, 1)
    } else {
        if (d == 350022200 && player.getMap().getNumMonsters() == 1) {
            player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
            player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
            player.getAPI().addPopupSay(1540453, 1500, "你在前面开路, #h0#!", "", 0)
        }
    }
    return 1
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}

function onMonsterDamaged() {}

function onItemPickedUp() {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
};